package com.yx.frame.http;

import java.util.HashMap;

public final class ContentTypeUtil {
	static HashMap<String,String> contentTypeList=new HashMap<String,String>();
	static{
		contentTypeList.put("aif", "audio/aiff");
		contentTypeList.put("aifc", "audio/aiff");
		contentTypeList.put("aiff", "audio/aiff");
		contentTypeList.put("anv", "application/x-anv");
		contentTypeList.put("asf", "video/x-ms-asf");		
		contentTypeList.put("asp", "text/asp");
		contentTypeList.put("asx", "video/x-ms-asf");
		contentTypeList.put("avi", "video/avi");
		contentTypeList.put("awf", "application/vnd.adobe.workflow");
		contentTypeList.put("bmp", "application/x-bmp");
		contentTypeList.put("class", "java/*");
		contentTypeList.put("css", "text/css");
		contentTypeList.put("dbf", "application/x-dbf");
		contentTypeList.put("dbm", "application/x-dbm");
		contentTypeList.put("dbx", "application/x-dbx");
		contentTypeList.put("dcd", "text/xml");
		contentTypeList.put("dll", "application/x-msdownload");
		contentTypeList.put("doc", "application/msword");
		contentTypeList.put("dot", "application/msword");
		contentTypeList.put("dtd", "text/xml");
		contentTypeList.put("exe", "application/x-msdownload");	
		contentTypeList.put("fax", "image/fax");	
		contentTypeList.put("fo", "text/xml");
		contentTypeList.put("gif", "image/gif");
		contentTypeList.put("htm", "text/html");
		contentTypeList.put("html", "text/html");
		contentTypeList.put("ico", "image/x-icon");
		contentTypeList.put("img", "application/x-img");	
		contentTypeList.put("java", "java/*");	
		contentTypeList.put("jpe", "image/jpeg");
		contentTypeList.put("jpeg", "image/jpeg");
		contentTypeList.put("jpg", "image/jpeg");
		contentTypeList.put("js", "application/x-javascript");
		contentTypeList.put("jsp", "text/html");
		contentTypeList.put("m1v", "video/x-mpeg");
		contentTypeList.put("m2v", "video/x-mpeg");
		contentTypeList.put("m3u", "audio/mpegurl");
		contentTypeList.put("m4e", "video/mpeg4");
		contentTypeList.put("math", "text/xml");
		contentTypeList.put("mfp", "application/x-shockwave-flash");
		contentTypeList.put("mp1", "audio/mp1");
		contentTypeList.put("mp2", "audio/mp2");
		contentTypeList.put("mp2v", "video/mpeg");	
		contentTypeList.put("mp3", "audio/mp3");	
		contentTypeList.put("mp4", "video/mpeg4");	
		contentTypeList.put("mpa", "video/x-mpg");	
		contentTypeList.put("mpe", "video/x-mpeg");	
		contentTypeList.put("mpeg", "video/mpg");	
		contentTypeList.put("mpg", "video/mpg");	
		contentTypeList.put("mpga", "audio/rn-mpeg");	
		contentTypeList.put("mps", "video/x-mpeg");	
		contentTypeList.put("mpv", "video/mpg");
		contentTypeList.put("mpv2", "video/mpeg");
		contentTypeList.put("pdf", "application/pdf");
		contentTypeList.put("png", "image/png");
		contentTypeList.put("ppt", "application/vnd.ms-powerpoint");
		contentTypeList.put("rtf", "application/msword");
		contentTypeList.put("swf", "application/x-shockwave-flash");
		contentTypeList.put("tif", "image/tiff");	
		contentTypeList.put("tiff", "image/tiff");	
		contentTypeList.put("tsd", "text/xml");	
		contentTypeList.put("txt", "text/plain");	
		contentTypeList.put("vsd", "application/x-vsd");
		contentTypeList.put("vss", "application/vnd.visio");
		contentTypeList.put("wav", "audio/wav");	
		contentTypeList.put("wbmp", "image/vnd.wap.wbmp");
		contentTypeList.put("wml", "text/vnd.wap.wml");
		contentTypeList.put("wmv", "video/x-ms-wmv");
		contentTypeList.put("wmx", "video/x-ms-wmx");
		contentTypeList.put("xhtml", "text/html");		
		contentTypeList.put("xls", "application/x-xls");
		contentTypeList.put("xml", "text/xml");
		contentTypeList.put("xsd", "text/xml");
		contentTypeList.put("xsl", "text/xml");
		contentTypeList.put("xslt", "text/xml");
	}
	public static final String getContentType(String fileName){
		String extendFileName="";
		if(fileName.lastIndexOf(".")>0){
			extendFileName=fileName.substring(fileName.lastIndexOf(".")+1);
			extendFileName=extendFileName.toLowerCase();
		}
		if(!"".equals(extendFileName)&&contentTypeList.containsKey(extendFileName)){
			return contentTypeList.get(extendFileName);
		}
		return "application/octet-stream";
	}
}
